package HashMap1;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;

public class Text1 {
   public int singleNumber(int[] nums) {
       HashMap<Integer, Integer>  map = new HashMap<>();
       for(int i = 0; i <nums.length;i++){
           int num = nums[i];
           map.put(num,map.getOrDefault(num,0) +1);

       }
       Set<Integer> keys  = map.keySet();
       Iterator<Integer> iterator = keys.iterator();
       while(iterator.hasNext()){
           int key = iterator.next();
           if(map.get(key) == 1){
               return key;
           }
       }
       return -1;
   }
}
